import matplotlib.pyplot as plt import numpy as np from PIL import Image import pandas as pd from collections import OrderedDict %matplotlib qt
cd "K:\Pat's_Projects\Hamamatsu LUT Generation"
no_lut = Image.open('No_LUT.png')
wl_780 = Image.open('780nm.png')
wl_790 = Image.open('790nm.png')
wl_800 = Image.open('800nm.png')
all_screens = [no_lut,wl_780,wl_790,wl_800]
np.array(no_lut.crop((1280,0,2080,600)).convert('LA').getdata())[:,0]
img_array = []
for img in all_screens:
cropped = img.crop((1280,0,2080,600))
img_array.append(np.array(cropped.convert('LA').getdata())[:,0].reshape((cropped.size[1],cropped.size[0])))
img_slice = []
for img in img_array:
img_slice.append(img[300,:])
file_names = ['780nm.lut','790nm.lut','800nm.lut']
for num,temp_slice in enumerate(img_slice[1:]):
temp = np.vstack((img_slice[0],temp_slice)).T.astype(np.int)
sort = np.sort(temp, axis=0)
# Use Pandas to drop duplicates and make back into array
sort = pd.DataFrame(sort).drop_duplicates().values
np.savetxt(file_names[num],sort,fmt='%d')